// pages/look_my1/look_my1.js
const app = getApp(), core = require('../../utils/core'), util = require('../../utils/util');
Page({

  /**
   * 页面的初始数据
   */
  data: {
    resumeList: [],
    resumeDateList: [],
    resumeDateMapList: {},
    resumeListMore: {page:1},
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.fetchResume();
  },

  fetchResume() {
    util.fetch(this, 'xilujob.resume/look_my', {}, 'resumeListMore', 'resumeList', 'data', list=>{
      list.forEach(resume=>{
        if(!resume.personal.realname && resume.job_intention.length<=0){
          return ;
        }
        let viewDate = util.formatDatetime(resume.view_time,'yyyy年m月d日');
        if(this.data.resumeDateList.indexOf(viewDate)===-1) {
          this.data.resumeDateList.push(viewDate);
        }
        resume.job_intention = resume.job_intention.length>0?resume.job_intention[0]:null;
        let resumeList = this.data.resumeDateMapList[viewDate] || [];
        resumeList.push(resume);
        this.setData({
          resumeDateList: this.data.resumeDateList,
          ['resumeDateMapList.'+viewDate]: resumeList
        });
      });
      return [];
    });
  },

});
